Calculate the lengthΒΆ
Calculate the length of a string.
def string_length(S):
count = 0
for char in S:
count += 1
return count
# test
print(string_length('python')) # 6
def string_length(S):
count = 0
for char in S:
count += 1
return count
# test
print(string_length('python')) # 6